import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'target_page.dart';

void main() {
  runApp(RootApp());
}

// runApp(
//       GetMaterialApp(
//         home: HomePage(),
//         routes: {
//           'target': (context) => TargetPage(),
//         },
//       ),
//     );

class RootApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //使用 GetX第一步
    return GetMaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
      debugShowCheckedModeBanner: false,
      routes: {
        '/target': (context) => TargetPage(),
      },
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("子页面"),
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Column(
          children: [
            ElevatedButton(
              child: Text("计数器页面"),
              onPressed: () {
                Get.to(() => TargetPage());
              },
            ),
          ],
        ),
      ),
    );
  }
}
